<html>
    <head><title>localStorage buffer loss testing</title></head>
    <body id="body">
        <p>The # of entries in localStorage is <span
            id="storage-count">###</span>.</p>
        <input type="text" size="6" name="item-count" id="item-count">
        <input type="button" name="start" id="start" value="Start">
        <script>
            var testString = [];
            for (var x=0; x < 100; x+=1) {
                testString.push('a');
            }
            testString = testString.join('');


            function run() {
                localStorage.clear();

                var body = document.getElementById("body");
                var itemCount = document.getElementById("item-count").value;

                for (x=0; x < itemCount; x+=1) {
                    localStorage.setItem(x.toString(), testString);
                }

                body.innerHTML = '<p style="font-size: xx-large; color: red;">QUIT</p>';
            }

            var button = document.getElementById("start");
            button.onclick = run;

            var storageCount = document.getElementById("storage-count");
            storageCount.innerHTML = localStorage.length;

        </script>
    </body>
</html>
